package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

@Entity
@Table(name = "tnb_drug_record")
@JsonApiResource(type = "drugRecord")
public class DrugRecord extends BaseEntity {
	private Integer createTime;
	private Integer isTaken;
	private Integer isInTime;
	private Customer customer;

	@Column(name = "create_time")
	public Integer getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Integer createTime) {
		this.createTime = createTime;
	}

	@Column(name = "is_taken")
	public Integer getIsTaken() {
		return isTaken;
	}

	public void setIsTaken(Integer isTaken) {
		this.isTaken = isTaken;
	}

	@Column(name = "is_in_time")
	public Integer getIsInTime() {
		return isInTime;
	}

	public void setIsInTime(Integer isInTime) {
		this.isInTime = isInTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "customer_id", foreignKey = @ForeignKey(name = "null"))
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
}
